<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>选择对象</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="https://cdn.bootcss.com/twitter-bootstrap/4.3.0/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="../../static/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Fontastic Custom icon font-->
    <link rel="stylesheet" href="../../static/css/fontastic.css">
    <!-- Google fonts - Poppins -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,700">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="http://cdn.jie12366.xyz/style.default.css" id="theme-stylesheet">
    <!-- Favicon-->
    <link rel="shortcut icon" href="../../static/img/favicon.ico">
    <style>
        .button-color {
            color: #6c757d;
        }
    </style>
</head>
<body>
<div class="page">
    <!-- Main Navbar-->
    <header th:replace="header::header"></header>
    <div class="page-content d-flex align-items-stretch">
        <nav th:replace="navbar::navbar"></nav>
        <div class="content-inner">
            <!-- Page Header-->
            <header class="page-header">
                <div class="container-fluid">
                    <h2 class="no-margin-bottom">选择对象</h2>
                </div>
            </header>
            <!-- Breadcrumb-->
            <div class="breadcrumb-holder container-fluid">
                <ul class="breadcrumb">
                    <li class="breadcrumb-item"><a href="/admin/index">主界面</a></li>
                    <li class="breadcrumb-item active"><a href="/admin/announce">公告栏</a></li>
                    <li class="breadcrumb-item active"><a href="/admin/toEmail">群发邮件</a></li>
                    <li class="breadcrumb-item active">选择对象</li>
                </ul>
            </div>
            <section class="tables">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-header d-flex align-items-center">
                                    <button type="button" class="btn btn-primary" onclick="select()">确定</button>
                                </div>
                                <div class="card-body">
                                    <h2>协会成员</h2>
                                    <div class="table-responsive">
                                        <table class="table table-striped table-hover">
                                            <thead>
                                            <tr>
                                                <th><input type="checkbox" id="allChecks" onclick="ckAll()"/></th>
                                                <th>#</th>
                                                <th>姓名</th>
                                                <th>邮箱</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr th:each="user:${pages1}">
                                                <td style="CURSOR: hand; HEIGHT: 10px" align="center" width="4"><input
                                                        type="checkbox" th:value="${user.email}" id="check" value=""
                                                        name="check"></td>
                                                <td th:text="${user.id}"></td>
                                                <td th:text="${user.name}"></td>
                                                <td th:text="${user.email}"></td>
                                            </tr>
                                            </tbody>
                                        </table>
                                </div>
                                <div class="card-body">
                                    <h2>比赛报名成员</h2>
                                    <div class="table-responsive">
                                        <table class="table table-striped table-hover">
                                            <thead>
                                            <tr>
                                                <th><input type="checkbox" id="allChecks1" onclick="ckAll()"/></th>
                                                <th>#</th>
                                                <th>姓名</th>
                                                <th>QQ邮箱</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr th:each="competition:${pages2}">
                                                <td style="CURSOR: hand; HEIGHT: 10px" align="center" width="4"><input
                                                        type="checkbox" th:value="${competition.qq}" id="check1"
                                                        value="" name="check1"></td>
                                                <td th:text="${competition.id}"></td>
                                                <td th:text="${competition.name}"></td>
                                                <td th:text="${competition.qq}"></td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- Page Footer-->
            <footer th:replace="footer::footer"></footer>
        </div>
    </div>
</div>
<!-- JavaScript files-->
<script>
    //全选
    function ckAll() {
        var flag = document.getElementById("allChecks").checked;
        var flag1 = document.getElementById("allChecks1").checked;
        var cks = document.getElementsByName("check");
        var cks1 = document.getElementsByName("check1");
        for (var i = 0; i < cks.length; i++) {
            cks[i].checked = flag;
        }
        for (var i = 0; i < cks1.length; i++) {
            cks1[i].checked = flag1;
        }
    }

    //批量删除announce
    function select() {
        var Checkbox = false;
        $("input[name='check']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        $("input[name='check1']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {
            var t = confirm("您确认要选择这些对象吗？");
            if (t == false) {
                return false;
            } else {
                var checkedEmail = "";
                $("input[name='check']").each(function () {
                    if (this.checked == true) {
                        checkedEmail += this.value + ",";

                    }
                });
                $("input[name='check1']").each(function () {
                    if (this.checked == true) {
                        checkedEmail += this.value + ",";
                    }
                });
                alert(checkedEmail);
                checkedEmail = checkedEmail.substring(0, checkedEmail.length - 1);
                window.location.replace("/admin/getSelect?emails=" + checkedEmail);
            }
        } else {
            alert("请选择您要发送的对象!");
            return false;
        }
    }
</script>
<!-- JavaScript files-->
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/4.3.0/js/bootstrap.min.js"></script>
</body>
</html>